package com.appleyk.config5;

import com.appleyk.annotation.DeferredEnableService;
import org.springframework.context.annotation.DeferredImportSelector;
import org.springframework.core.type.AnnotationMetadata;

import java.util.Map;

/**
 * <p>越努力，越幸运</p>
 *
 * @author appleyk
 * @version V.0.1.1
 * @blob https://blog.csdn.net/appleyk
 * @date created on  10:38 下午 2020/12/9
 */
public class DeferredServiceSelector implements DeferredImportSelector {

    @Override
    public String[] selectImports(AnnotationMetadata annotationMetadata) {
        System.out.println("配置类："+annotationMetadata.getClassName());
        Map<String, Object> attributes = annotationMetadata
                .getAnnotationAttributes(DeferredEnableService.class.getName());
        if(attributes.containsValue("B")){
            return new String[]{ConfigB.class.getName()};
        }
        return new String[0];
    }

}
